3.684 \(\int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx\)

Optimal. Leaf size=91 \[ -\frac {a^2 (A-3 i B)}{c^2 f (\tan (e+f x)+i)}+\frac {a^2 (B+i A)}{c^2 f (\tan (e+f x)+i)^2}-\frac {a^2 B \log (\cos (e+f x))}{c^2 f}-\frac {i a^2 B x}{c^2} \]

[Out]

-I*a^2*B*x/c^2-a^2*B*ln(cos(f*x+e))/c^2/f+a^2*(I*A+B)/c^2/f/(tan(f*x+e)+I)^2-a^2*(A-3*I*B)/c^2/f/(tan(f*x+e)+I
)

________________________________________________________________________________________

Rubi [A]  time = 0.15, antiderivative size = 91, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, integrand size = 41, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.049, Rules used = {3588, 77} \[ -\frac {a^2 (A-3 i B)}{c^2 f (\tan (e+f x)+i)}+\frac {a^2 (B+i A)}{c^2 f (\tan (e+f x)+i)^2}-\frac {a^2 B \log (\cos (e+f x))}{c^2 f}-\frac {i a^2 B x}{c^2} \]

Antiderivative was successfully verified.

[In]

Int[((a + I*a*Tan[e + f*x])^2*(A + B*Tan[e + f*x]))/(c - I*c*Tan[e + f*x])^2,x]

[Out]

((-I)*a^2*B*x)/c^2 - (a^2*B*Log[Cos[e + f*x]])/(c^2*f) + (a^2*(I*A + B))/(c^2*f*(I + Tan[e + f*x])^2) - (a^2*(
A - (3*I)*B))/(c^2*f*(I + Tan[e + f*x]))

Rule 77

Int[((a_.) + (b_.)*(x_))*((c_) + (d_.)*(x_))^(n_.)*((e_.) + (f_.)*(x_))^(p_.), x_Symbol] :> Int[ExpandIntegran
d[(a + b*x)*(c + d*x)^n*(e + f*x)^p, x], x] /; FreeQ[{a, b, c, d, e, f, n}, x] && NeQ[b*c - a*d, 0] && ((ILtQ[
n, 0] && ILtQ[p, 0]) || EqQ[p, 1] || (IGtQ[p, 0] && ( !IntegerQ[n] || LeQ[9*p + 5*(n + 2), 0] || GeQ[n + p + 1
, 0] || (GeQ[n + p + 2, 0] && RationalQ[a, b, c, d, e, f]))))

Rule 3588

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[(a*c)/f, Subst[Int[(a + b*x)^(m - 1)*(c + d*x)^(n - 1)*(A + B*x), x
], x, Tan[e + f*x]], x] /; FreeQ[{a, b, c, d, e, f, A, B, m, n}, x] && EqQ[b*c + a*d, 0] && EqQ[a^2 + b^2, 0]

Rubi steps

\begin {align*} \int \frac {(a+i a \tan (e+f x))^2 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx &=\frac {(a c) \operatorname {Subst}\left (\int \frac {(a+i a x) (A+B x)}{(c-i c x)^3} \, dx,x,\tan (e+f x)\right )}{f}\\ &=\frac {(a c) \operatorname {Subst}\left (\int \left (-\frac {2 i a (A-i B)}{c^3 (i+x)^3}+\frac {a (A-3 i B)}{c^3 (i+x)^2}+\frac {a B}{c^3 (i+x)}\right ) \, dx,x,\tan (e+f x)\right )}{f}\\ &=-\frac {i a^2 B x}{c^2}-\frac {a^2 B \log (\cos (e+f x))}{c^2 f}+\frac {a^2 (i A+B)}{c^2 f (i+\tan (e+f x))^2}-\frac {a^2 (A-3 i B)}{c^2 f (i+\tan (e+f x))}\\ \end {align*}

________________________________________________________________________________________

Mathematica [B]  time = 3.61, size = 184, normalized size = 2.02 \[ \frac {a^2 (\cos (2 (e+2 f x))+i \sin (2 (e+2 f x))) \left (-i \cos (2 (e+f x)) \left (A-2 i B \log \left (\cos ^2(e+f x)\right )+8 B f x-i B\right )+A \sin (2 (e+f x))-8 B f x \sin (2 (e+f x))-i B \sin (2 (e+f x))+2 i B \sin (2 (e+f x)) \log \left (\cos ^2(e+f x)\right )+4 B \tan ^{-1}(\tan (3 e+f x)) (\sin (2 (e+f x))+i \cos (2 (e+f x)))+4 B\right )}{4 c^2 f (\cos (f x)+i \sin (f x))^2} \]

Antiderivative was successfully verified.

[In]

Integrate[((a + I*a*Tan[e + f*x])^2*(A + B*Tan[e + f*x]))/(c - I*c*Tan[e + f*x])^2,x]

[Out]

(a^2*(4*B - I*Cos[2*(e + f*x)]*(A - I*B + 8*B*f*x - (2*I)*B*Log[Cos[e + f*x]^2]) + A*Sin[2*(e + f*x)] - I*B*Si
n[2*(e + f*x)] - 8*B*f*x*Sin[2*(e + f*x)] + (2*I)*B*Log[Cos[e + f*x]^2]*Sin[2*(e + f*x)] + 4*B*ArcTan[Tan[3*e
+ f*x]]*(I*Cos[2*(e + f*x)] + Sin[2*(e + f*x)]))*(Cos[2*(e + 2*f*x)] + I*Sin[2*(e + 2*f*x)]))/(4*c^2*f*(Cos[f*
x] + I*Sin[f*x])^2)

________________________________________________________________________________________

fricas [A]  time = 0.69, size = 62, normalized size = 0.68 \[ \frac {{\left (-i \, A - B\right )} a^{2} e^{\left (4 i \, f x + 4 i \, e\right )} + 4 \, B a^{2} e^{\left (2 i \, f x + 2 i \, e\right )} - 4 \, B a^{2} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right )}{4 \, c^{2} f} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x, algorithm="fricas")

[Out]

1/4*((-I*A - B)*a^2*e^(4*I*f*x + 4*I*e) + 4*B*a^2*e^(2*I*f*x + 2*I*e) - 4*B*a^2*log(e^(2*I*f*x + 2*I*e) + 1))/
(c^2*f)

________________________________________________________________________________________

giac [B]  time = 1.91, size = 201, normalized size = 2.21 \[ -\frac {\frac {6 \, B a^{2} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 1\right )}{c^{2}} - \frac {12 \, B a^{2} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + i\right )}{c^{2}} + \frac {6 \, B a^{2} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 1\right )}{c^{2}} + \frac {25 \, B a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{4} + 12 \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} + 112 i \, B a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} - 198 \, B a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 12 \, A a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 112 i \, B a^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 25 \, B a^{2}}{c^{2} {\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + i\right )}^{4}}}{6 \, f} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x, algorithm="giac")

[Out]

-1/6*(6*B*a^2*log(tan(1/2*f*x + 1/2*e) + 1)/c^2 - 12*B*a^2*log(tan(1/2*f*x + 1/2*e) + I)/c^2 + 6*B*a^2*log(tan
(1/2*f*x + 1/2*e) - 1)/c^2 + (25*B*a^2*tan(1/2*f*x + 1/2*e)^4 + 12*A*a^2*tan(1/2*f*x + 1/2*e)^3 + 112*I*B*a^2*
tan(1/2*f*x + 1/2*e)^3 - 198*B*a^2*tan(1/2*f*x + 1/2*e)^2 - 12*A*a^2*tan(1/2*f*x + 1/2*e) - 112*I*B*a^2*tan(1/
2*f*x + 1/2*e) + 25*B*a^2)/(c^2*(tan(1/2*f*x + 1/2*e) + I)^4))/f

________________________________________________________________________________________

maple [A]  time = 0.25, size = 116, normalized size = 1.27 \[ \frac {3 i a^{2} B}{f \,c^{2} \left (\tan \left (f x +e \right )+i\right )}-\frac {a^{2} A}{f \,c^{2} \left (\tan \left (f x +e \right )+i\right )}+\frac {a^{2} B \ln \left (\tan \left (f x +e \right )+i\right )}{f \,c^{2}}+\frac {i a^{2} A}{f \,c^{2} \left (\tan \left (f x +e \right )+i\right )^{2}}+\frac {a^{2} B}{f \,c^{2} \left (\tan \left (f x +e \right )+i\right )^{2}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x)

[Out]

3*I/f*a^2/c^2/(tan(f*x+e)+I)*B-1/f*a^2/c^2/(tan(f*x+e)+I)*A+1/f*a^2/c^2*B*ln(tan(f*x+e)+I)+I/f*a^2/c^2/(tan(f*
x+e)+I)^2*A+1/f*a^2/c^2/(tan(f*x+e)+I)^2*B

________________________________________________________________________________________

maxima [F(-2)]  time = 0.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: RuntimeError} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))^2*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative e
xponent.

________________________________________________________________________________________

mupad [B]  time = 8.71, size = 104, normalized size = 1.14 \[ -\frac {a^2\,\left (B\,2{}\mathrm {i}+A\,\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}+3\,B\,\mathrm {tan}\left (e+f\,x\right )+B\,\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,1{}\mathrm {i}+2\,B\,\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\mathrm {tan}\left (e+f\,x\right )-B\,\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,{\mathrm {tan}\left (e+f\,x\right )}^2\,1{}\mathrm {i}\right )\,1{}\mathrm {i}}{c^2\,f\,{\left (-1+\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}\right )}^2} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(((A + B*tan(e + f*x))*(a + a*tan(e + f*x)*1i)^2)/(c - c*tan(e + f*x)*1i)^2,x)

[Out]

-(a^2*(B*2i + A*tan(e + f*x)*1i + 3*B*tan(e + f*x) + B*log(tan(e + f*x) + 1i)*1i + 2*B*log(tan(e + f*x) + 1i)*
tan(e + f*x) - B*log(tan(e + f*x) + 1i)*tan(e + f*x)^2*1i)*1i)/(c^2*f*(tan(e + f*x)*1i - 1)^2)

________________________________________________________________________________________

sympy [A]  time = 0.63, size = 163, normalized size = 1.79 \[ - \frac {B a^{2} \log {\left (e^{2 i f x} + e^{- 2 i e} \right )}}{c^{2} f} + \begin {cases} - \frac {- 4 B a^{2} c^{2} f e^{2 i e} e^{2 i f x} + \left (i A a^{2} c^{2} f e^{4 i e} + B a^{2} c^{2} f e^{4 i e}\right ) e^{4 i f x}}{4 c^{4} f^{2}} & \text {for}\: 4 c^{4} f^{2} \neq 0 \\- \frac {x \left (- A a^{2} e^{4 i e} + i B a^{2} e^{4 i e} - 2 i B a^{2} e^{2 i e}\right )}{c^{2}} & \text {otherwise} \end {cases} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))**2*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))**2,x)

[Out]

-B*a**2*log(exp(2*I*f*x) + exp(-2*I*e))/(c**2*f) + Piecewise((-(-4*B*a**2*c**2*f*exp(2*I*e)*exp(2*I*f*x) + (I*
A*a**2*c**2*f*exp(4*I*e) + B*a**2*c**2*f*exp(4*I*e))*exp(4*I*f*x))/(4*c**4*f**2), Ne(4*c**4*f**2, 0)), (-x*(-A
*a**2*exp(4*I*e) + I*B*a**2*exp(4*I*e) - 2*I*B*a**2*exp(2*I*e))/c**2, True))

________________________________________________________________________________________